<!DOCTYPE html>
<html>

<head>

   {include file="Public/header"}
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
     <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/sc/js/page.js"></script> 
     <style>
        .quxiao{color:red;text-decoration: line-through;}
        .is_yd{color:blue;text-decoration: line-through;}
    </style>
</head>

<body style="color:#333;padding:3px;">
    <!-- 标题 -->
    <div class="page-heade">
      <h2 class="title_color text-center">AP费用申请 </h2>
    </div>
    <!-- 标题 -->
    <div>
    <form action="#" method="post" id="form_check"  class="form-inline formpage">
      <input type="hidden" value='{$page}' name="page" id="page-go"/>
                      <input type="hidden" value='{$list}' name="list" id="list-go"/>
      <table class="row-margin-top tab-content table-bordered table text-center" border="1">
          <tr>
            <td class="text-left" colspan="8" rowspan=""><a href="{:url('Apapply/addform')}" class="btn btn-sm btn-primary">新增AP费用申请</a></td>
          </tr>
           <tr>
                <td><label for="" class="form-label">编号：</label><input type="text" class="form-control" name="no" value="{$data.no}"></td>
                <td><label for="">主题：</label><input type="text" class="form-control" name="title" value="{$data.title}"></td>
                <td><label for="">状态：</label>
                    <select name="state" id="state" class="form-control" style="min-width: 100px;width: 100px">
                        <option value="0">请选择</option>
                        {volist name="states" id="sta"}
                        {if condition="$data.state eq $sta.id"}
                        <option value="{$sta.id}" selected>{$sta.title}</option>
                        {else/}
                        <option value="{$sta.id}">{$sta.title}</option>
                        {/if}
                        {/volist}
                    </select></td>
                <td>
                    <div class="form-group">
                        申请时间
                    </div>
                    <div class="form-group">
                        <input type="text" id="start" placeholder="开始日期" class="form-control layer-date "
                               style="min-width:100px;height: 22px;display: inline-block;" name="start" value="{$data.start}">
                    </div>
                    <div class="form-group">
                        至
                    </div>
                    <div class="form-group">
                        <input type="text" class="form-control layer-date" placeholder="结束日期"
                               style="min-width:100px;height: 22px;display: inline-block;" id="end" name="end" value="{$data.end}">
                    </div>
                </td>
                <td>
                    <button class="btn btn-sm btn-info query" type="button" id="check">查询</button>
                    <button class="btn btn-sm btn-info emptyIf" type="button" id="clear_check">清空查询条件</button>
                </td>
            </tr>
      </table>
    
      <table class="table table-striped table-bordered table-hover bud_hei text-center">
          <tr class="info text-center">
            <th class="text-center">NO.</th>
            <th class="text-center">类型</th>
            <th class="text-center">编号</th>
            <th class="text-center">主题</th>
            <th class="text-center">状态</th>
            <th class="text-center">申请人</th>
            <th class="text-center">申请时间</th>
            <th class="text-center">操作</th>
          </tr>
           {volist name="applys" id="vo"}
              <tr class="text-center">
                <td>{$i}</td>
                <td>AP费用{if condition="$vo.is_actived eq 0 "}取消{else/}{if condition="$vo.yuantag eq 1"}异动{else/}申请{/if}{/if}</td>
                <td><a href="{:url('apply_de')}?aid={$vo.id}"  class="J_menuItem" title="{$vo.no}">{$vo.no}</a></td>
                <td>
                    {if condition="$vo.tag eq 2"}
                   <span class="quxiao">
                   {elseif condition="$vo.tag eq 1"/}
                    <span class="is_yd">
                    {else/}
                    <span>
                   {/if}
                           {$vo.title}         
                     
                     
                      </span>  
                     
                        {if condition="$vo.tag eq 0"}
                            
                           
                             {if condition="$vo.is_shengxiao eq 1"}
                                <span class="glyphicon glyphicon-ok duigou" title="已生效" aria-hidden="true"></span>
                            {/if}
                             {if condition="$vo.is_fankui neq 0"}
                                <span class="glyphicon glyphicon-send fankui" title="已反馈" aria-hidden="true"></span>
                            {/if}
                             {if condition="$vo.is_hexiao neq 0"}
                                <span class="glyphicon glyphicon-yen fankui" style="color:gold;" title="已核销" aria-hidden="true"></span>
                            {/if}
                        {elseif condition="$vo.tag eq 1"}
                         <!--异动图标-->
                           <span class="glyphicon glyphicon-remove delCssY" style="color:blue;" title="已异动" aria-hidden="true"></span>
                        {elseif condition="$vo.tag eq 2"}
                         <!--删除图标-->
                           <span class="glyphicon glyphicon-remove delCssQ" title="已删除" aria-hidden="true"></span>
                        {/if}
                    
                    
                </td>
                <td>{$vo.zhuangtai}</td>
                <td>{$vo.cname}</td>
                <td>{$vo.created_on}</td>
                <td>
                {if condition="$vo.tag eq 0"}
                          {if condition="$vo.is_actived eq 1"}
                            {switch name="$vo.state" }
                                
                                
                                {case value="1"}
                                <!--草稿-->
                                    <a onclick="gostate(1,{$vo.id})">提交工作流</a>
                                    {if $vo.yuan_id}
                                    {else/}
                                    <a href="{:url('addform')}?aid={$vo.id}">修改</a>
                                    {/if}
                                    <a onclick="shanchu({$vo.id})">删除</a>
                                    
                                {/case}
                                {case value="2"}
                                <!--打回-->
                                     {if $vo.yuan_id}
                                      <a href="{:url('zuofeiyd')}?aid={$vo.id}">作废</a>
                                    {else/}
                                    <a href="{:url('addform')}?aid={$vo.id}">修改/作废</a>
                                    {/if}
                                    <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                                {/case}
                                 {case value="7"}
                                <!--已归档-->
                                    {if condition="$vo.is_hexiao eq 0"}
                                        {if condition="$vo.tag eq 0"}
                                         {if $vo.is_fankui==0&&$vo.isqxyd==0}
                                        <a onclick="yidong({$vo.id})">异动</a>
                                        <a onclick="quxiao({$vo.id})">取消</a>
                                       
                                        
                                        {/if}
                                        {if $vo.isqxyd==0}
                                          {if condition="$vo.weifan eq 0"}
                                          <a class="feedback" aid="{$vo.id}">反馈</a>
                                          {/if}
                                        <a onclick="hexiao({$vo.id})">核销</a>
                                        {/if}
                                        <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                                        {else/}
                                        <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                                        {/if}
                                    {else/}
                                    {if $vo.isqxyd==0}
                                         {if condition="$vo.weifan eq 0"}
                                          <a class="feedback" aid="{$vo.id}">反馈</a>
                                          {/if}
                                        <a onclick="hexiao({$vo.id})">核销</a>
                                        {/if}
                                        <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                                    {/if}
                                {/case}
                                {default/} <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                            {/switch}
                        {else/}
                            {switch name="$vo.state" }
                                
                                {case value="1"}
                                <!--草稿-->
                                    <a onclick="gostate(1,{$vo.id})">提交工作流</a>
                                    
                                    <a onclick="shanchuqx({$vo.id})">删除</a>
                                    
                                {/case}
                                {case value="2"}
                                   <a href="{:url('qxzuofei')}?aid={$vo.id}">修改/作废</a>
                                  <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                                {/case}
                                {default/} <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                            {/switch}
                        {/if}

                {else/}

                    <a href="{:url('Workflowdb/workflowchart',['id'=>$vo.myId])}" class="J_menuItem" title="查看流程图">查看流程图</a>
                {/if}

              
                </td>
            </tr>
            {/volist}
      </table>
       <h5 class="text-center" id="pagesc" style="font-size: 16px;font-weight: 500">
            <script>
                            $(function(){
                                pageSC("pagesc",{$sum},{$page},{$maxpage})
                            })
                        </script> 
                        每页显示
           <select id="pagesize">
                        <option value='20' {if condition="$list eq 20"}selected{/if}>20条</option>
                        <option value='40'{if condition="$list eq 40"}selected{/if}>40条</option>
                        <option value='50'{if condition="$list eq 50"}selected{/if}>50条</option>

            </select>
        </h5>
</form>
    </div>
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
    <!-- <script src="js/plugins/metisMenu/jquery.metisMenu.js"></script> -->
    <script src="__STATIC__/layout/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
    <!--统计代码，可删除-->
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
    <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<script src="__STATIC__/layout/js/contabs_sub.js"></script>
    <script>
    //删除申请

function shanchu(apid){
    if(confirm("您真的要删除这个申请么？")){
       $.post("{:url('shanchuap')}",{aid:apid},function(re){
                  var data=JSON.parse(re);
                  if(data["state"]==1){
                        alert("删除成功");
                          document.getElementById("form_check").submit();
                      
                  }else{
                        swal({
                                title: "错误",
                                 text: data["msg"],
                                 type: "warning"
                              });
                      }
            })
    }
   
}
    //详情也
function xiangqing(aid){
     var index = layer.open({
                            type:2,
                            title:'AP费用申请',
                            area:['100%','100%'],
                            maxmin:true,
                            content:'{:url("apply_de")}?aid='+aid
                        })
}
    function hexiao(aid){
     
        location.href="{:url('hexiao')}?aid="+aid;
    }
    $(".feedback").click(function(){
         location.href="{:url('fankui')}?aid="+$(this).attr("aid");

    })
    function shanchuqx(apid){
    swal({
            title: "提示",
            text: "您真的要删除这个申请么？",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#FF3333",
            confirmButtonText: "是的我要删除",
            cancelButtonText: "取消",
            closeOnConfirm: true
        },
        function (isConfirm) {
            if (isConfirm) {
                 $.post("{:url('shanchuqx')}",{aid:apid},function(re){
                   // alert(re);
            var data=JSON.parse(re);
            if(data["state"]==1){
                alert("删除成功");
                    document.getElementById("form_check").submit();
                
            }else{
                  swal({
                          title: "错误",
                           text: data["msg"],
                           type: "warning"
                        });
                }
            })
        }
    })
}
    //取消
      function quxiao(apid){
        location.href="{:url('quxiao')}?aid="+apid;
       
    }
    //异动
    function yidong(aid){
    location.href="{:url('yidong')}?aid="+aid;
}
//查询
     
        $("#check").click(function(){
              $("#page-go").val(1);
             $(".formpage").submit();
        })
        $("#clear_check").click(function(){
            $("input[type='text']").val("");
            $("select").val(0);
            $("#page-go").val(1);
             $(".formpage").submit();
        })

        //日期范围限制
        var start = {
            elem: '#start',
            format: 'YYYY/MM/DD',
            min: laydate.now(), //设定最小日期为当前日期
            max: '2099-06-16 23:59:59', //最大日期
            istime: true,
            istoday: false,
            choose: function (datas) {
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };
        var end = {
            elem: '#end',
            format: 'YYYY/MM/DD',
            min: laydate.now(),
            max: '2099-06-16 23:59:59',
            istime: true,
            istoday: false,
            choose: function (datas) {
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
        laydate(start);
        laydate(end);
//审核
function shenhe(apid){
      swal({
            title: "提示",
            text: "您真的要审核这个申请么？",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#33FF33",
            confirmButtonText: "是的我要审核",
            cancelButtonText: "取消",
            closeOnConfirm: true
        }, function (isConfirm) {
            if (isConfirm) {
                 $.post("{:url('shapply')}",{aid:apid},function(re){
                   // alert(re);
                 if(re==1){
                swal({
                            title: "完成",
                           text: "成功审核申请",
                           type: "success"

                },function(){
                    document.getElementById("form_check").submit();
                })
            }else{
                  swal({
                          title: "错误",
                           text: "系统繁忙请稍后再试",
                           type: "warning"
                        });
                }

                 })
            }
        })
}
    //提交工作流
function gostate(state,apid){
        $.post("{:url('gostate')}",{aid:apid,state:state},function(re){
            var data=JSON.parse(re);
            if(data["state"]==1){
                swal({
                            title: "完成",
                           text: "成功提交工作流",
                           type: "success"

                },function(){
                    document.getElementById("form_check").submit();
                })
            }else{
                  swal({
                          title: "错误",
                           text: data["msg"],
                           type: "warning"
                        });
            }
        })
}

    </script>
</body>

</html>
